// components/shuichi.js
const App = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    detail:{
      type:Object,
      value:{}
    },
    index:{
      type:Number,
      value:0
    },
    isEdit:{
      type:Boolean,
      value:false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    isYouwuList: [{
        value: '有'
      },
      {
        value: '无'
      },
    ],
    isYouwuQList: [{
        value: '有'
      },
      {
        value: '无'
      },
      {
        value: '其它'
      },
    ],
    isShifouList: [{
        value: '是'
      },
      {
        value: '否'
      },
    ],
    ErGongDiXiaShuiChiCaiZhiList: [{
        value: '瓷砖内饰面'
      },
      {
        value: '不锈钢'
      },
      {
        value: '混凝土'
      },
      {
        value: '其它'
      },
    ],
    YiLiuGuanJuTiList: [{
        value: '空气隔断'
      },
      {
        value: '倒流防止器          '
      }
    ],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    radioChange(e) {
      let _this = this
      if (e.target.dataset.name) {
        let data = {}
        data[e.target.dataset.name] = e.detail.value
        _this.setData(data)
      }
    },
    formSubmit(e){
      let  data  = e.detail.value;
      data.LeiXing = this.data.detail.LeiXing
      data.index = this.data.index
      this.triggerEvent('save',data)
    },
    cancel(){
      let _this =this
     wx.showModal({
       title:'确定不保存直接关闭吗？',
       showCancel:'true',
       cancelColor: 'cancelColor',
       success:(res)=>{
         if(res.confirm){
          this.triggerEvent('cancel')
         }
       }
     })
    },
    delete(){
      wx.showModal({
        title:'确定要删除吗？',
        showCancel:'true',
        cancelColor: 'cancelColor',
        success:(res)=>{
          if(res.confirm){
           this.triggerEvent('delete',this.data.detail)
          }
        }
      })
    }
  }
})